package org.hy.corn_task.utils;

import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.extension.service.IService;
import okhttp3.FormBody;
import okhttp3.Headers;
import okhttp3.Request;
import okhttp3.RequestBody;
import org.hy.corn_task.pojo.entity.source.Dept;
import org.hy.corn_task.service.target.YsgzBdcR1Service;
import org.springframework.stereotype.Component;

import java.io.IOException;

@Component
public class ExeTask {


    public JSONObject exeAPITask(String url, Headers header, Dept dept) throws IOException {

        //请求参数添加到body
        RequestBody body = new FormBody.Builder().add("name", dept.getDeptName()).build();
        //创建Request示例对象
        Request request = ResRequestUtil.buildPostRequest(url, header, body);
        //request发起请求
        return ResRequestUtil.doPostRequest(request);

    }

}
